﻿<%@ CODEPAGE=65001 %>
<%
'///////////////////////////////////////////////////////////////////////////////
'// 插件应用:    Z-Blog 2.0 其它版本未知
'// 插件制作:    狼的旋律(http://www.wilf.cn) / zsx(http://www.zsxsoft.com)
'// 备    注:    RSS
'// 最后修改:
'// 最后版本:
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../../zb_system/function/c_function.asp" -->
<!-- #include file="../../../zb_system/function/c_system_lib.asp" -->
<!-- #include file="../../../zb_system/function/c_system_base.asp" -->
<!-- #include file="../../../zb_system/function/c_system_plugin.asp" -->
<!-- #include file="../p_config.asp" -->
<%
Call System_Initialize()
Call WindsPhoto_Initialize()

If CheckpluginState("windsphoto") = False Then Call ShowError(48)

Dim sXmlClear,sRssHead,sRssEnd

sXmlClear = "<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>" & VBCRLF
'Media RSS
sRssHead = "<rss version=""2.0"" xmlns:media=""http://search.yahoo.com/mrss/"" xmlns:dc=""http://purl.org/dc/elements/1.1/"">" & VBCRLF
sRssHead = sRssHead & "<channel>" & VBCRLF
sRssHead = sRssHead & "<title>"& WP_ALBUM_NAME &"</title>" & VBCRLF
sRssHead = sRssHead & "<link>"& WP_SUB_DOMAIN &"</link>" & VBCRLF
sRssHead = sRssHead & "<description>Powered by WindsPhoto</description>" & VBCRLF
sRssHead = sRssHead & "<language>zh-cn</language>" & VBCRLF
sRssHead = sRssHead & "<generator>WindsPhoto RSS</generator>" & VBCRLF

sRssEnd = "</channel></rss>"

Response.Contenttype = "text/xml"

Response.Write sXmlClear
Response.Write sRssHead

Dim rs2,sql2,nopass
sql2 = "select * from windsphoto_zhuanti where pass<>''"
nopass = 0
Set rs2 = server.CreateObject("adodb.recordset")
rs2.Open sql2, objconn, 1, 1
Do While Not rs2.EOF
	nopass = nopass &","& rs2("id")
    rs2.movenext
Loop
rs2.Close
Set rs2 = Nothing

Dim rs,sql,id,surl,url,name,jj,typeid,itime,link
Set rs = server.CreateObject("adodb.recordset")
If Request.QueryString("id") = "" or IsNumeric(Request.QueryString("id")) = False Then
    sql = "select top 20 * from windsphoto_desktop where zhuanti not in ("&nopass&") order by id desc"
Else
    id = Request.QueryString("id")
    sql = "select top 20 * from windsphoto_desktop where zhuanti="&id&" order by id desc"
End If
rs.Open sql, objconn, 1, 1
Do While Not rs.EOF
    surl = rs("surl")
    url = rs("url")
	If Left(url, 4)<>"http" Then url = WP_SUB_DOMAIN & url End If
    If Left(surl, 4)<>"http" Then surl = WP_SUB_DOMAIN & surl End If
    typeid = rs("zhuanti")
    jj = rs("jj")
    If WP_SCRIPT_TYPE <> 4 Then link=url Else link = WP_SUB_DOMAIN & "display.asp?id=" & rs("id") End If
    If rs("name")<>"" Then name = rs("name") Else name = "未命名" End If
    If rs("itime")<>"" Then itime=ParseDateForRFC822(rs("itime")) Else itime=ParseDateForRFC822(now()) End If
    Response.Write "<item>"& VBCRLF
    Response.Write "<title><![CDATA["&name&"]]></title>"& VBCRLF
    Response.Write "<pubDate>" & itime & "</pubDate>"& VBCRLF
    Response.Write "<link>"& link &"</link>"& VBCRLF
    Response.Write "<description><![CDATA[<div align=center><a href="""& link &""" target=""_blank""><img src="""& url &"""></a></div>"& jj &"]]></description>"& VBCRLF
    Response.Write "<media:content url="""& url &""" type=""image/jpeg"" />"& VBCRLF
    Response.Write "<media:title>" & name & "</media:title>"& VBCRLF
    Response.Write "<media:text type=""html""><![CDATA["& jj &"]]></media:text>"& VBCRLF
    Response.Write "<media:thumbnail url="""& url &""" />"& VBCRLF
    Response.Write "</item>"& VBCRLF
    rs.movenext
Loop
rs.Close
Set rs = Nothing

Response.Write sRssEnd

'转换时间格式
Function ParseDateForRFC822(dtmDate)

    Dim dtmDay, dtmWeekDay, dtmMonth, dtmYear
    Dim dtmHours, dtmMinutes, dtmSeconds
    Dim TimeZone
    TimeZone = "+0800"

    Select Case WeekDay(dtmDate)
        Case 1:dtmWeekDay="Sun"
        Case 2:dtmWeekDay="Mon"
        Case 3:dtmWeekDay="Tue"
        Case 4:dtmWeekDay="Wed"
        Case 5:dtmWeekDay="Thu"
        Case 6:dtmWeekDay="Fri"
        Case 7:dtmWeekDay="Sat"
    End Select

    Select Case Month(dtmDate)
        Case 1:dtmMonth="Jan"
        Case 2:dtmMonth="Feb"
        Case 3:dtmMonth="Mar"
        Case 4:dtmMonth="Apr"
        Case 5:dtmMonth="May"
        Case 6:dtmMonth="Jun"
        Case 7:dtmMonth="Jul"
        Case 8:dtmMonth="Aug"
        Case 9:dtmMonth="Sep"
        Case 10:dtmMonth="Oct"
        Case 11:dtmMonth="Nov"
        Case 12:dtmMonth="Dec"
    End Select

    dtmYear = Year(dtmDate)
    dtmDay = Right("00" & Day(dtmDate),2)

    dtmHours = Right("00" & Hour(dtmDate),2)
    dtmMinutes = Right("00" & Minute(dtmDate),2)
    dtmSeconds = Right("00" & Second(dtmDate),2)

    ParseDateForRFC822 = dtmWeekDay & ", " & dtmDay &" " & dtmMonth & " " & dtmYear & " " & dtmHours & ":" & dtmMinutes & ":" & dtmSeconds & " " & TimeZone

End Function

Call System_Terminate()
%>